<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no">
    <title>登录</title>
    <link rel="stylesheet" href="css/aui.css" />
    <link rel="stylesheet" href="./css/index.css">
    <link rel="stylesheet" href="./css/style.css" />
</head>
<body class="login-bg">
    <div class="login-contain">
        <header class="aui-bar aui-bar-nav aui-background-transparent aui-position-fixed aui-bar-nav-search aui-text-default">
			<a class="aui-pull-left aui-btn" href="JavaScript:history.go(-1)">
				<span class="aui-iconfont aui-icon-left aui-text-white aui-font-size-14"></span>
			</a>
			<div class="aui-title aui-font-weight aui-text-white title aui-font-size-16">
				登录
			</div>
		</header>
       
        <div class="form-group">
            <div class="form-item">
                <label for="phone">
                    <img src="images/phone.png" alt="">
                </label>
                <input id="username" type="text" placeholder="请输入手机号">
            </div>
            <div class="form-item">
                <label for="code">
                    <img src="images/code.png" alt="">
                </label>
                <input id="password" type="password" placeholder="请输入密码">
            </div>
        </div>
        <div class="button-group">
            <button class="login-btn" onclick="login()">登录</button>
            <button onclick="register()" class="login-register">注册</button>
        </div>
        <!-- <div class="casual">
            <a href="#">随便逛逛</a>
        </div> -->
        <div class="order-login">
            <p>使用第三方账号登录</p>
            <ul>
                <li>
                    <a href="#" onclick="qqlogin()">
                        <img src="images/qq.png" alt="">
                    </a>
                </li>
                
                <li>
                    <a href="#">
                        <img src="images/blog.png" alt="">
                    </a>
                </li>
				<li>
				    <a href="#" onclick="wxlogin()">
				        <img src="images/WeChat.png" alt="">
				    </a>
				</li>
            </ul>
        </div>
        <!-- <div class="copyright">
            该技术由如你所喜欢提供
        </div> -->
    </div>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/layer/layer.js"></script>
<script type="text/javascript">
	//登录
	var uid  = window.localStorage.getItem('uid');
	if (uid !=null) {
		window.location.href='./index.html';
	}
	var baseurl = 'http://kt.zhangzhengjiang.top/api/';
	function login(){
		var username = $('#username').val();
		var password = $('#password').val();
		if (username&&password) {
			$.ajax({
				url:baseurl+'user/login',
				type:'post',
				data:{account:username,password:password},
				success:function(res){
				
					if (res.code==1) {
						window.localStorage.setItem('uid',res.data.userinfo.id);
						window.localStorage.setItem('avatar',res.data.userinfo.avatar);
						window.localStorage.setItem('mobile',res.data.userinfo.mobile);
						window.localStorage.setItem('score',res.data.userinfo.score);
						window.localStorage.setItem('username',res.data.userinfo.username);
						window.localStorage.setItem('nicknmame',res.data.userinfo.nickname);
						window.localStorage.setItem('juese',res.data.userinfo.juese);
						layer.open({
							content: '登录成功'
							,skin: 'msg'
							,time: 2 ,//2秒后自动关闭
							success: function(elem){
							  
							  setTimeout(function(){
								  window.location.href='./index.html';
							  },2000)
							}    
						});
					}else{
						layer.open({
							content: res.msg
							,skin: 'msg'
							,time: 2 ,//2秒后自动关闭 
						});
					}
				}
			})
		}else{
			layer.open({
				content: '请完善信息后提交'
				,skin: 'msg'
				,time: 2 ,//2秒后自动关闭
				
			});
		}
	}
	function register(){
		window.location.href='./register.html';
	}
	function qqlogin(){
		layer.open({
			content: '敬请期待'
			,skin: 'msg'
			,time: 2 ,//2秒后自动关闭 
		});
	}
	function wxlogin(){
		layer.open({
			content: '敬请期待'
			,skin: 'msg'
			,time: 2 ,//2秒后自动关闭 
		});
	}
</script>
</body>
</html>
